<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>for循环</title>
    <script>
        function fundo(){
            for(var i =1;i<=20;i++){
                console.log(i)
            }
        }
        function funAdd100(){
            var sum = 0
            for (var i =1;i<=100;i++) {
                sum += i
            }
            console.log(sum)
        }
        function funEven(){
            var sum = 0
            for (var i =1;i<=100;i++){
                if (i%2!=0){
                    sum +=i
                }
            }
            console.log(sum)
        }

        function funBreak(){
            for(var i=1;i<=7;i++){
                if (i==3){
                    break
                }
                console.log(i)
            }
        }
        function funContinue(){
            for(var i=1;i<=7;i++){
                if (i==3){
                    continue
                }
                console.log(i)
            }
        }
        function funX(){
            for(var i=1;i<=9;i++){
                console.log('1x'+ i +'='+ i)
            }
        }
        function funXX(){
            for(var i=1 ; i<=9 ;i++){
                var line=''
                for (var j =1 ;j<=i;j++){
                    line += j +"x"+ i +"=" + i*j + "  "
                }
                console.log(line)
            }
        }

    </script>
</head>
<body>
    <button onclick="fundo()">循环20</button>
    <button onclick="funAdd100()">1-100之和</button>
    <button onclick="funEven()">1-100偶数和</button>
    <button onclick="funContinue()">跳过3</button>
    <button onclick="funBreak()">结束3</button>
    <button onclick="funX()">X</button>
    <button onclick="funXX()">乘法口诀</button>
</body>
</html>